<?php
namespace app\common\validate;
use think\Validate;
use think\Request;
class Favorites extends Validate{
    protected $rule =   [
        'contentid' => 'number',
    ];

    protected $message  =   [
        
    ];
    protected $scene = [
        'check_contentid' => ['contentid'=>'require|checkContentid'],
    ];
    
    protected function checkContentid($value, $rule=[], $data){
        $count = model("Favorites")->where('userid', $data['userid'])->where('contentid', $value)->where('typeid', $data['typeid'])->count();
        if ($count) {
        	return '已收藏';
        }
        return true;
    }
}